package com.ds.infrastructure.hyperspace.console.model.request.containerconfig.configdata;

import com.ds.infrastructure.hyperspace.console.dto.configdata.ResourcesDTO;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

/**
 * @author: yaozhendong
 * @create: 2019-09-23 09:36
 **/
@Data
@NoArgsConstructor
public class ResourcesForm {
    @NotBlank
    private String name;
    @NotBlank
    private String ip;
    @NotBlank
    private String cpu;
    @NotNull
    @ApiModelProperty(value = "资源类型:1(VM);2(Docker)")
    private Integer resourcesType;
    @NotBlank
    private String ram;
    @NotBlank
    private String disk;

    public static ResourcesDTO toDTO(ResourcesForm form) {
        ResourcesDTO resourcesDTO = new ResourcesDTO();
        resourcesDTO.setName(form.getName());
        resourcesDTO.setIp(form.getIp());
        resourcesDTO.setCpu(form.getCpu());
        resourcesDTO.setResourcesType(form.getResourcesType());
        resourcesDTO.setRam(form.getRam());
        resourcesDTO.setDisk(form.getDisk());
        return resourcesDTO;
    }

    public static ResourcesForm toVO(ResourcesDTO dto) {
        ResourcesForm resourcesFrom = new ResourcesForm();
        resourcesFrom.setName(dto.getName());
        resourcesFrom.setIp(dto.getIp());
        resourcesFrom.setCpu(dto.getCpu());
        resourcesFrom.setResourcesType(dto.getResourcesType());
        resourcesFrom.setRam(dto.getRam());
        resourcesFrom.setDisk(dto.getDisk());
        return resourcesFrom;
    }

}
